﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.FxCop.Sdk;

namespace LINQtoFxCop.Core
{
  public class NamespaceCollection : MemberCollection<Namespace>
  {
    public void Add(IEnumerable<TypeNode> types)
    {
      types.Where(type => !type.IsModuleType()).ForEach(Add);
    }

    public void Add(TypeNode type)
    {
      if (!Contains(new Namespace(type.Namespace)))
        Add(new Namespace(type.Namespace));
      var member = this[new Namespace(type.Namespace)];
      member.Add(type);
    }
  }
}
